package com.esri.core.tasks.na;

import com.esri.core.geometry.Geometry;
import com.esri.core.geometry.GeometryEngine;
import com.esri.core.internal.util.d;
import com.esri.core.map.SpatialFilter;
import com.esri.core.tasks.SpatialRelationship;
import java.io.StringWriter;
import org.codehaus.jackson.JsonGenerator;

/* loaded from: classes.dex */
public class NAFeaturesAsLayer implements NAFeatures {
    private Boolean doNotLocateOnRestrictedElements;
    private String layerName;
    private SpatialFilter spatialFilter;
    private String where;

    public NAFeaturesAsLayer() {
        this.layerName = null;
        this.where = null;
        this.spatialFilter = null;
        this.doNotLocateOnRestrictedElements = null;
    }

    public NAFeaturesAsLayer(String str) {
        this.layerName = null;
        this.where = null;
        this.spatialFilter = null;
        this.doNotLocateOnRestrictedElements = null;
        this.layerName = str;
    }

    public NAFeaturesAsLayer(String str, String str2) {
        this.layerName = null;
        this.where = null;
        this.spatialFilter = null;
        this.doNotLocateOnRestrictedElements = null;
        this.layerName = str;
        this.where = str2;
    }

    public NAFeaturesAsLayer(String str, SpatialFilter spatialFilter) {
        this.layerName = null;
        this.where = null;
        this.spatialFilter = null;
        this.doNotLocateOnRestrictedElements = null;
        this.layerName = str;
        this.spatialFilter = spatialFilter;
    }

    public String getLayerName() {
        return this.layerName;
    }

    public void setLayerName(String str) {
        this.layerName = str;
    }

    public String getWhere() {
        return this.where;
    }

    public void setWhere(String str) {
        this.where = str;
    }

    public SpatialFilter getSpatialFilter() {
        return this.spatialFilter;
    }

    public void setSpatialFilter(SpatialFilter spatialFilter) {
        this.spatialFilter = spatialFilter;
    }

    public Boolean isDoNotLocateOnRestrictedElements() {
        return this.doNotLocateOnRestrictedElements;
    }

    public void setDoNotLocateOnRestrictedElements(Boolean bool) {
        this.doNotLocateOnRestrictedElements = bool;
    }

    @Override // com.esri.core.tasks.na.NAFeatures
    public String toJson() throws Exception {
        Geometry geometry;
        StringWriter stringWriter = new StringWriter();
        JsonGenerator a = d.a(stringWriter);
        a.writeStartObject();
        a.writeStringField("type", "layer");
        String str = this.layerName;
        if (str != null) {
            a.writeStringField("layerName", str);
            String str2 = this.where;
            if (str2 != null) {
                a.writeStringField("where", str2);
            }
            SpatialFilter spatialFilter = this.spatialFilter;
            if (spatialFilter != null && (geometry = spatialFilter.getGeometry()) != null) {
                SpatialRelationship spatialRelationship = this.spatialFilter.getSpatialRelationship();
                try {
                    a.writeStringField("geometry", GeometryEngine.geometryToJson(null, geometry));
                    if (spatialRelationship != null) {
                        a.writeStringField("spatialRel", spatialRelationship.toString());
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            Boolean bool = this.doNotLocateOnRestrictedElements;
            if (bool != null) {
                a.writeStringField("doNotLocateOnRestrictedElements", bool.toString());
            }
            a.writeEndObject();
            a.close();
            return stringWriter.toString();
        }
        throw new IllegalArgumentException("Must specify layer name for route features");
    }

    public int hashCode() {
        int i = ((this.doNotLocateOnRestrictedElements.booleanValue() ? 1231 : 1237) + 31) * 31;
        String str = this.layerName;
        int hashCode = (i + (str == null ? 0 : str.hashCode())) * 31;
        SpatialFilter spatialFilter = this.spatialFilter;
        int hashCode2 = (hashCode + (spatialFilter == null ? 0 : spatialFilter.hashCode())) * 31;
        String str2 = this.where;
        return hashCode2 + (str2 != null ? str2.hashCode() : 0);
    }

    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj != null && getClass() == obj.getClass()) {
            NAFeaturesAsLayer nAFeaturesAsLayer = (NAFeaturesAsLayer) obj;
            if (this.doNotLocateOnRestrictedElements != nAFeaturesAsLayer.doNotLocateOnRestrictedElements) {
                return false;
            }
            String str = this.layerName;
            if (str == null) {
                if (nAFeaturesAsLayer.layerName != null) {
                    return false;
                }
            } else if (!str.equals(nAFeaturesAsLayer.layerName)) {
                return false;
            }
            SpatialFilter spatialFilter = this.spatialFilter;
            if (spatialFilter == null) {
                if (nAFeaturesAsLayer.spatialFilter != null) {
                    return false;
                }
            } else if (!spatialFilter.equals(nAFeaturesAsLayer.spatialFilter)) {
                return false;
            }
            String str2 = this.where;
            if (str2 == null) {
                if (nAFeaturesAsLayer.where != null) {
                    return false;
                }
            } else if (!str2.equals(nAFeaturesAsLayer.where)) {
                return false;
            }
            return true;
        }
        return false;
    }
}
